import React, { Component } from "react";
import { Table, Button, Modal } from "antd";

export default class Relation extends Component {
  columns = [
    {
      title: "用户名",
      dataIndex: "name",
    },
    {
      title: "收益",
      dataIndex: "income",
    },
    {
      title: "状态",
      dataIndex: "direct",
      render: (e) => (e ? "直推" : "间推"),
    },
    // {
    //   title: "操作",
    //   dataIndex: "",
    //   render: (e) => (
    //     <Space>
    //       <Button
    //         size="small"
    //         type="primary"
    //         onClick={() => {
    //           this.freezeClick(e);
    //         }}
    //       >
    //         {e.isFreeze ? "解除" : "冻结"}
    //       </Button>
    //     </Space>
    //   ),
    // },
  ];
  state = {
    multiData: [],
    selectedItem: null,
    showModal: false,
    showEditModal: false,
  };
  returnBack = () => {
    this.props.history.replace("/user");
  };
  getData = async () => {
    this.setState({
      loading: true,
    });
    const res = await this.http("User/relationShip", {
      userId: this.props.match.params.id,
    });
    this.setState({
      loading: false,
      multiData: res.data,
    });
  };
  componentDidMount() {
    this.getData();
  }
  render() {
    return (
      <div>
        <Button className="header" onClick={this.returnBack} type="primary">
          返回
        </Button>
        <Modal
          visible={this.state.showModal}
          onOk={this.handleFreeze}
          onCancel={() => {
            this.setState({ showModal: false, selectedItem: null });
          }}
        >
          确定冻结吗？
        </Modal>
        <Table
          rowKey={(data) => data.id}
          loading={this.state.loading}
          columns={this.columns}
          dataSource={this.state.multiData}
        />
      </div>
    );
  }
}
